package com.netease.spring.ch2;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.netease.spring.exceptions.PerformanceException;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        ApplicationContext applicationContext = new FileSystemXmlApplicationContext(
                "ch2_Juggler.xml");
        testJuggler(applicationContext);
        System.out.println();
        testPoeticJuggler(applicationContext);
    }

    public static void testJuggler(ApplicationContext applicationContext) {
        Performer performer = (Performer) applicationContext.getBean("duke");
        try {
            performer.perform();
        } catch (PerformanceException e) {
            e.printStackTrace();
        }
    }

    public static void testPoeticJuggler(ApplicationContext applicationContext) {
        Performer performer = (Performer) applicationContext
                .getBean("dukeWithPoem");
        try {
            performer.perform();
        } catch (PerformanceException e) {
            e.printStackTrace();
        }
    }

}
